package example.simpleservice1;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {

	protected static final String TAG = "MyService";
	boolean doneWorking = false;
	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		Log.v(TAG, "i am started!");
		runningThread.start();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		runningThread.interrupt();
		doneWorking = true;
		Log.v(TAG, "i am destroyed!");
	}

	Thread runningThread = new Thread(){
		
		public void run() {
			for(;!doneWorking;){
				Log.i(TAG, "i am running in background!");
				try {
					sleep(1000);
				} catch (InterruptedException e) {}
			}
		};
	};

}
